package pub.cleangao.memm.loadbalance;


import pub.cleangao.memm.transport.message.RpcRequest;

import java.util.List;

public class LoadBalancer {

    private static final LoadBalance loadBalancer = new ConsistencyHashLoadBalancer();

    public static String selectOne(List<String> serviceAddresses, RpcRequest rpcRequest, List<String> excepts) {
        if (excepts != null && !excepts.isEmpty()) {
            serviceAddresses.removeAll(excepts);
        }
        if (serviceAddresses.isEmpty()) {
            return loadBalancer.selectServiceAddress(excepts, rpcRequest);
        }
        return loadBalancer.selectServiceAddress(serviceAddresses, rpcRequest);
    }


}
